package www.webols.api;

import org.json.JSONException;
import org.json.JSONObject;

import android.util.Log;

import www.webols.WeibolsException;

public class WeiboApiError extends WeibolsException {
	private String errorName;
	private int errorCode=0;
	private int httpCode=0;
	private String request;
	
	public static final int ERROR_CODE_EXPIRED_TOKEN=21327;
	public static final int ERROR_CODE_EXPIRED_INVALID_GRANT=21325;
	/**
	 * 
	 */
	private static final long serialVersionUID = 7612020318658316082L;

	@Override
	public int getTypeID() {
		return EXCEPTION_TYPEID_API;
	}

	public WeiboApiError(int httpCode,String jsonResult) {
		super();
		this.httpCode=httpCode;
		try {
			JSONObject json=new JSONObject(jsonResult);
			this.errorCode=json.getInt("error_code");
			this.errorName=json.getString("error");
		} catch (JSONException e) {
			Log.e("Unknow Exception:",e.getMessage());
		}
	}

	public String getErrorName() {
		return errorName;
	}

	public void setErrorName(String errorName) {
		this.errorName = errorName;
	}

	public int getErrorCode() {
		return errorCode;
	}

	public void setErrorCode(int errorCode) {
		this.errorCode = errorCode;
	}

	public int getHttpCode() {
		return httpCode;
	}

	public void setHttpCode(int httpCode) {
		this.httpCode = httpCode;
	}

	public String getRequest() {
		return request;
	}

	public void setRequest(String request) {
		this.request = request;
	}

	public WeiboApiError(String detailMessage, Throwable throwable) {
		super(detailMessage, throwable);
		// TODO Auto-generated constructor stub
	}

	public WeiboApiError(String detailMessage) {
		super(detailMessage);
		// TODO Auto-generated constructor stub
	}

	public WeiboApiError(Throwable throwable) {
		super(throwable);
		// TODO Auto-generated constructor stub
	}
	


}
